<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>mail</title>
    <link rel="stylesheet" charset="UTF-8" href="/layui/css/layui.css">
    <link rel="stylesheet" charset="UTF-8" href="/layui/css/global.css">
    <script charset="UTF-8" rel="script" src="/layui/layui.js"></script>

</head>
<body>
<div class="layui-container"
     style="margin-top: 50px;margin-bottom:50px;width: 500px; border: 1px #F6F6F6 solid;background-color: #ffffff">
    <form class="layui-form layui-form-pane" action="/mail/sendMail" method="post">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
            <legend>邮件发送界面</legend>
        </fieldset>
        <div class="layui-form-item">
            <label class="layui-form-label">收件人邮箱</label>
            <div class="layui-input-inline">
                <input type="text" name="toemail" autocomplete="off" lay-verify="required|email"
                       placeholder="请输入收件人邮箱 ..." class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">邮件主题</label>
            <div class="layui-input-inline">
                <input type="text" name="totheme" lay-verify="required" placeholder="请输入邮件主题 ..." autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">邮件内容</label>
            <div class="layui-input-block">
                <textarea placeholder="请输入内容" class="layui-textarea" lay-verify="required" name="tocontent"></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">单行选择框</label>
            <div class="layui-input-inline">
                <select name="interest" lay-filter="aihao">
                    <option value=""></option>
                    <option value="0">写作</option>
                    <option value="1" selected="">阅读</option>
                    <option value="2">游戏</option>
                    <option value="3">音乐</option>
                    <option value="4">旅行</option>
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">复选框</label>
            <div class="layui-input-block">
                <input type="checkbox" name="like" value="写作" title="写作">
                <input type="checkbox" name="like" value="阅读" title="阅读" checked="">
                <input type="checkbox" name="like" value="游戏" title="游戏">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">单选框</label>
            <div class="layui-input-block">
                <input type="radio" name="sex" value="男" title="男" checked="">
                <input type="radio" name="sex" value="女" title="女">
                <input type="radio" name="sex" value="禁" title="禁用" disabled="">
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">日期选择</label>
                <div class="layui-input-inline">
                    <input type="text" name="date" id="date1" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">普通表单</label>
                <div class="layui-input-inline">
                    <input type="text" name="number" autocomplete="off" class="layui-input" placeholder="普通表单请输入...">
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">密码框</label>
                <div class="layui-input-inline">
                    <input type="password" name="userpassword" autocomplete="off" class="layui-input"
                           placeholder="请输入密码...">
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">日期时间选择器</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" id="test5" name="date1" placeholder="yyyy-MM-dd HH:mm:ss">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <button class="layui-btn" lay-submit="" lay-filter="demo2">提交</button>
        </div>
    </form>
</div>

<script>
    layui.use(['jquery', 'form', 'layedit', 'layer', 'laydate', 'table'], function () {
        var $ = layui.jquery
            , layer = layui.layer
            , table = layui.table
            , form = layui.form
            , layedit = layui.layedit
            , laydate = layui.laydate;

        //日期
        laydate.render({
            elem: '#date1'
            , type: 'datetime'
            , theme: '#FFDCF7'
            , format: 'yyyy年MM月dd日 HH时mm分ss秒'
        });
        laydate.render({
            elem: '#test5'
            , type: 'datetime'
            , theme: '#393D49'
            , format: 'yyyy:MM:dd HH:mm:ss'
            , trigger: 'mouseenter'
        });

        //创建一个编辑器
        var editIndex = layedit.build('LAY_demo_editor');

        //自定义验证规则
        form.verify({
            title: function (value) {
                if (value.length < 5) {
                    return '标题至少得5个字符啊';
                }
            }
            , pass: [
                /^[\S]{6,12}$/
                , '密码必须6到12位，且不能出现空格'
            ]
            , content: function (value) {
                layedit.sync(editIndex);
            }
        });

        //监听指定开关
        form.on('switch(switchTest)', function (data) {
            layer.msg('开关checked：' + (this.checked ? 'true' : 'false'), {
                offset: '6px'
            });
            layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是ON|OFF', data.othis)
        });

        //监听提交
        form.on('submit(demo1)', function (data) {
            layer.alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            })
            return true;
        });
    });
</script>
</body>
</html>